package com.ytjj.qmyx.mall.utils;


import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.*;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HttpUtils {

    /**
     * get请求
     *
     * @param url url
     * @return JSONObject报文
     * @throws IOException IOException
     */
    public static JSONObject httpGet(String url) throws IOException {
        // get请求返回结果
        JSONObject jsonResult = null;
        DefaultHttpClient client = new DefaultHttpClient();
        // 发送get请求
        HttpGet request = new HttpGet(url);
        HttpResponse response = client.execute(request);

        /** 请求发送成功，并得到响应 **/
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            /** 读取服务器返回过来的json字符串数据 **/
            String strResult = EntityUtils.toString(response.getEntity(),
                    "UTF-8");
            /** 把json字符串转换成json对象 **/
            jsonResult = JSONObject.parseObject(strResult);
            URLDecoder.decode(url, "UTF-8");
        }

        return jsonResult;
    }

    /**
     * get 请求
     *
     * @param host    请求域名
     * @param uri     请求地址
     * @param headers 请求头
     * @param query   参数
     * @return 报文
     * @throws Exception Exception
     */
    public static String doGet(String host, String uri, Map<String, String> headers, Map<String, String> query) throws Exception {
        HttpClient httpClient = wrapClient(host);
        HttpGet request = new HttpGet(buildUrl(host, uri, query));
        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }
        return toStr(httpClient.execute(request));
    }


    /**
     * post 请求
     *
     * @param host    请求域名
     * @param uri     请求地址
     * @param headers 请求头
     * @param query   参数
     * @param body    内容
     * @return 报文
     * @throws Exception ex
     */
    public static String doPost(String host, String uri, Map<String, String> headers, Map<String, String> query, Map<String, String> body) throws Exception {
        HttpClient httpClient = wrapClient(host);

        HttpPost request = new HttpPost(buildUrl(host, uri, query));
        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }

        if (body != null) {
            List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();

            for (String key : body.keySet()) {
                nameValuePairList.add(new BasicNameValuePair(key, body.get(key)));
            }
            UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
            formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
            request.setEntity(formEntity);
        }

        return toStr(httpClient.execute(request));
    }

    /**
     * 发送 POST 请求（HTTP），JSON形式
     *
     * @param host    请求域名
     * @param uri     请求地址
     * @param headers 请求头
     * @param json    json参数
     * @return 报文
     */
    public static String doPost(String host, String uri, Map<String, String> headers, Object json) {
        HttpClient httpClient = wrapClient(host);
        String res = null;
        HttpPost httpPost = new HttpPost(host + uri);
        HttpResponse response = null;
        for (Map.Entry<String, String> e : headers.entrySet()) {
            httpPost.addHeader(e.getKey(), e.getValue());
        }
        try {
            StringEntity stringEntity = new StringEntity(json.toString(), "UTF-8");
            stringEntity.setContentEncoding("UTF-8");
            stringEntity.setContentType("application/json;charset=UTF-8");
            httpPost.setEntity(stringEntity);
            response = httpClient.execute(httpPost);
            HttpEntity entity = response.getEntity();
            System.out.println(response.getStatusLine().getStatusCode());
            res = EntityUtils.toString(entity, "UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (response != null) {
                try {
                    EntityUtils.consume(response.getEntity());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return res;
    }

    /**
     * Post String 请求
     *
     * @param host    请求域名
     * @param uri     请求地址
     * @param headers 请求头
     * @param query   参数
     * @param body    内容
     * @return 报文
     * @throws Exception ex
     */
    public static String doPost(String host, String uri, Map<String, String> headers, Map<String, String> query, String body) throws Exception {
        HttpClient httpClient = wrapClient(host);
        HttpPost request = new HttpPost(buildUrl(host, uri, query));
        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }
        if (StringUtils.isNotBlank(body)) {
            request.setEntity(new StringEntity(body, "utf-8"));
        }
        return toStr(httpClient.execute(request));
    }

    /**
     * Post stream 请求
     *
     * @param host    请求域名
     * @param uri     请求地址
     * @param headers 请求头
     * @param query   参数
     * @param body    内容
     * @return 报文
     * @throws Exception ex
     */
    public static String doPost(String host, String uri, Map<String, String> headers, Map<String, String> query, byte[] body) throws Exception {
        HttpClient httpClient = wrapClient(host);
        HttpPost request = new HttpPost(buildUrl(host, uri, query));
        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }
        if (body != null) {
            request.setEntity(new ByteArrayEntity(body));
        }
        return toStr(httpClient.execute(request));
    }

    /**
     * Put String 请求
     *
     * @param host    请求域名
     * @param uri     请求地址
     * @param headers 请求头
     * @param query   参数
     * @param body    内容
     * @return 报文
     * @throws Exception ex
     */
    public static String doPut(String host, String uri, Map<String, String> headers, Map<String, String> query, String body) throws Exception {
        HttpClient httpClient = wrapClient(host);
        HttpPut request = new HttpPut(buildUrl(host, uri, query));
        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }
        if (StringUtils.isNotBlank(body)) {
            request.setEntity(new StringEntity(body, "utf-8"));
        }
        return toStr(httpClient.execute(request));
    }

    /**
     * Put stream  请求
     *
     * @param host    请求域名
     * @param uri     请求地址
     * @param headers 请求头
     * @param query   参数
     * @param body    内容
     * @return 报文
     * @throws Exception ex
     */
    public static String doPut(String host, String uri, Map<String, String> headers, Map<String, String> query, byte[] body) throws Exception {
        HttpClient httpClient = wrapClient(host);
        HttpPut request = new HttpPut(buildUrl(host, uri, query));
        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }
        if (body != null) {
            request.setEntity(new ByteArrayEntity(body));
        }
        return toStr(httpClient.execute(request));
    }

    /**
     * Delete 请求
     *
     * @param host    请求域名
     * @param uri     请求地址
     * @param headers 请求头
     * @param query   参数
     * @return 报文
     * @throws Exception ex
     */
    public static String doDelete(String host, String uri, Map<String, String> headers, Map<String, String> query) throws Exception {
        HttpClient httpClient = wrapClient(host);
        HttpDelete request = new HttpDelete(buildUrl(host, uri, query));
        for (Map.Entry<String, String> e : headers.entrySet()) {
            request.addHeader(e.getKey(), e.getValue());
        }
        return toStr(httpClient.execute(request));
    }


    /**
     * 构建请求
     *
     * @param host   请求域名
     * @param uri    请求地址
     * @param querys 参数
     * @return 报文
     * @throws UnsupportedEncodingException UnsupportedEncodingException
     */
    private static String buildUrl(String host, String uri, Map<String, String> querys) throws UnsupportedEncodingException {
        StringBuilder sbUrl = new StringBuilder();
        sbUrl.append(host);
        if (!StringUtils.isBlank(uri)) {
            sbUrl.append(uri);
        }
        if (null != querys) {
            StringBuilder sbQuery = new StringBuilder();
            for (Map.Entry<String, String> query : querys.entrySet()) {
                if (0 < sbQuery.length()) {
                    sbQuery.append("&");
                }
                if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
                    sbQuery.append(query.getValue());
                }
                if (!StringUtils.isBlank(query.getKey())) {
                    sbQuery.append(query.getKey());
                    if (!StringUtils.isBlank(query.getValue())) {
                        sbQuery.append("=");
                        sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
                    }
                }
            }
            if (0 < sbQuery.length()) {
                sbUrl.append("?").append(sbQuery);
            }
        }
        return sbUrl.toString();
    }

    /**
     * 根据请求类型获取HttpClient
     *
     * @param host 请求域名
     * @return HttpClient
     */
    private static HttpClient wrapClient(String host) {
        HttpClient httpClient = new DefaultHttpClient();

//        HttpClient httpClient = HttpClients.createDefault();
        if (host.startsWith("https://")) {
            sslClient(httpClient);
        }
        return httpClient;
    }

    /**
     * 判断请求类型
     *
     * @param p12      证书的输入流
     * @param password 密码
     * @return HttpClient
     */
    private static HttpClient wrapClient(InputStream p12, String password) {
        return sslClient(p12, password);
    }

    /**
     * 绕过SSL
     *
     * @param httpClient httpClient
     */
    private static void sslClient(HttpClient httpClient) {
        try {
            SSLContext ctx = SSLContext.getInstance("TLS");
            X509TrustManager tm = new X509TrustManager() {
                @Override
                public X509Certificate[] getAcceptedIssuers() {
                    return null;
                }

                @Override
                public void checkClientTrusted(X509Certificate[] xcs, String str) {
                }

                @Override
                public void checkServerTrusted(X509Certificate[] xcs, String str) {
                }
            };
            ctx.init(null, new TrustManager[]{tm}, null);
            SSLSocketFactory ssf = new SSLSocketFactory(ctx);
            ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
            ClientConnectionManager ccm = httpClient.getConnectionManager();
            SchemeRegistry registry = ccm.getSchemeRegistry();
            registry.register(new Scheme("https", 443, ssf));
        } catch (KeyManagementException ex) {
            throw new RuntimeException(ex);
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException(ex);
        }
    }

    /**
     * 转换请求结果为字符串
     *
     * @param httpResponse httpResponse
     * @return 报文
     * @throws IOException IOException
     */
    public static String toStr(HttpResponse httpResponse) throws IOException {
        return EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
    }


    /**
     * 创建没有证书的SSL链接工厂类
     *
     * @return SSLConnectionSocketFactory
     * @throws NoSuchAlgorithmException NoSuchAlgorithmException
     * @throws KeyStoreException        KeyStoreException
     * @throws KeyManagementException   KeyManagementException
     */
    public static SSLConnectionSocketFactory getSSLConnectionSocketFactory() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
        SSLContextBuilder context = new SSLContextBuilder();
        context.loadTrustMaterial(null, new TrustStrategy() {
            @Override
            public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
                return true;
            }
        });
        return new SSLConnectionSocketFactory(context.build());
    }

    /**
     * 链接GET请求
     *
     * @param url url
     * @return 报文
     * @throws KeyManagementException   KeyManagementException
     * @throws NoSuchAlgorithmException NoSuchAlgorithmException
     * @throws KeyStoreException        KeyStoreException
     * @throws ClientProtocolException  ClientProtocolException
     * @throws IOException              IOException
     */
    public static String connectGetUrl(String url) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, ClientProtocolException, IOException {
        SSLConnectionSocketFactory socketFactory = getSSLConnectionSocketFactory();
        CloseableHttpClient client = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
        RequestConfig config = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(5000).build();
        HttpGet httpGet = null;
        CloseableHttpResponse resp = null;
        String jsonString = "";
        try {
            httpGet = new HttpGet(url);
            httpGet.setConfig(config);
            resp = client.execute(httpGet);
            HttpEntity entity = resp.getEntity();
            jsonString = EntityUtils.toString(entity, "UTF-8");
        } finally {
            if (resp != null) {
                try {
                    resp.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (httpGet != null) {
                httpGet.releaseConnection();
            }
        }
        return jsonString;
    }

    /**
     * 链接POST请求
     *
     * @param url       url
     * @param jsonParam json参数
     * @return 报文
     * @throws Exception ex
     */
    public static String connectPostUrl(String url, String jsonParam) throws Exception {
        SSLConnectionSocketFactory socketFactory = getSSLConnectionSocketFactory();
        CloseableHttpClient client = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
        RequestConfig config = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(5000).build();
        return request(url, config, jsonParam, client);
    }

    /**
     * 链接POST请求 请求时间加长
     *
     * @param url       url
     * @param jsonParam json参数
     * @return 报文
     * @throws Exception ex
     */
    public static String connectPostUrl2(String url, String jsonParam) throws Exception {
        SSLConnectionSocketFactory socketFactory = getSSLConnectionSocketFactory();
        CloseableHttpClient client = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
        RequestConfig config = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(10000).build();
        return request(url, config, jsonParam, client);
    }

    /**
     * 请求
     *
     * @param url       url
     * @param config    RequestConfig
     * @param jsonParam json参数
     * @param client    HttpClient
     * @return 报文
     * @throws Exception ex
     */
    private static String request(String url, RequestConfig config, String jsonParam, CloseableHttpClient client) throws Exception {
        HttpPost httpPost = null;
        CloseableHttpResponse resp = null;
        try {
            httpPost = new HttpPost(url);
            httpPost.setConfig(config);
            StringEntity params = new StringEntity(jsonParam, "UTF-8");
            params.setContentType("application/json");
            httpPost.setEntity(params);
            resp = client.execute(httpPost);
            HttpEntity entity = resp.getEntity();
            String jsonString = EntityUtils.toString(entity, "UTF-8");

            if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                return jsonString;
            }
        } catch (IOException e) {
            if (e instanceof org.apache.http.conn.ConnectTimeoutException) {
                throw new org.apache.http.conn.ConnectTimeoutException("connect timed out");
            }
            if (e instanceof java.net.SocketTimeoutException) {
                throw new java.net.SocketTimeoutException("Read timed out");
            }
            throw new IOException("IOException");
        } finally {
            if (resp != null) {
                try {
                    resp.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (httpPost != null) {
                httpPost.releaseConnection();
            }
            try {
                client.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }


    /**
     * 携带证书的httpClient请求
     *
     * @param p12      证书的输入流
     * @param password 密码
     * @return HttpClient
     */
    private static HttpClient sslClient(InputStream p12, String password) {
        try {
            BasicHttpClientConnectionManager connManager;
            // 证书
            char[] pwd = password.toCharArray();
            KeyStore ks = KeyStore.getInstance("PKCS12");
            ks.load(p12, pwd);

            // 实例化密钥库 & 初始化密钥工厂
            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks, pwd);

            // 创建 SSLContext
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(kmf.getKeyManagers(), null, new SecureRandom());

            SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new String[]{"TLSv1"}, null, new DefaultHostnameVerifier());

            connManager = new BasicHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sslConnectionSocketFactory).build(), null, null, null);

            return HttpClientBuilder.create().setConnectionManager(connManager).build();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                p12.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }


    /**
     * post 发送xml参数请求
     *
     * @param host    域名
     * @param uri     地址
     * @param xmlData xml格式的参数
     * @return 报文
     */
    public static String doPostXml(String host, String uri, String xmlData) {
        HttpClient httpClient = wrapClient(host);
        return doPostXml(httpClient, host, uri, xmlData);
    }

    /**
     * post 发送xml参数请求
     *
     * @param httpClient http客户端
     * @param host       域名
     * @param uri        地址
     * @param xmlData    xml格式的参数
     * @return 报文
     */
    public static String doPostXml(HttpClient httpClient, String host, String uri, String xmlData) {
        try {
            HttpPost post = new HttpPost(host + uri);
            post.setHeader("Content-Type", "text/xml; charset=utf-8");
            post.setEntity(new StringEntity(xmlData, "UTF-8"));
            HttpResponse response = httpClient.execute(post);
            HttpEntity entity = response.getEntity();
            String result = EntityUtils.toString(entity, "UTF-8");
            return result;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * post 发送xml参数请求（有证书的双向请求）
     *
     * @param host     域名
     * @param uri      地址
     * @param xmlData  xml格式的参数
     * @param p12      p12类型的证书输入流
     * @param password 证书密码
     * @return 报文
     */
    public static String doPostXml(String host, String uri, String xmlData, InputStream p12, String password) {
        HttpClient httpClient = wrapClient(p12, password);
        return doPostXml(httpClient, host, uri, xmlData);
    }

    /**
     * 读取请求中参数
     *
     * @param request HttpServletRequest
     * @param clazz   返回值得class
     * @param <T>     返回值泛型
     * @return 报文
     */
    public static <T> T readerRequestParam(HttpServletRequest request, Class<T> clazz) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line = null;
            while ((line = br.readLine()) != null) {
                sb = sb.append(line);
            }
            String postData = sb.toString();
            if (StringUtils.isNotBlank(postData)) {
                if (clazz.equals(String.class)) {
                    return (T) postData;
                }
                return JSONObject.parseObject(postData, clazz);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String readerRequestParam(HttpServletRequest request) {
        return readerRequestParam(request, String.class);
    }

    /**
     * 上传图片到指定路径
     *
     * @param imagedata 图片字节
     * @param url 上传的路径
     * @return
     */
    public static String upload(byte[] imagedata, String url) throws Exception {
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();
        CloseableHttpResponse httpResponse = null;
        RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(200000).setSocketTimeout(200000000).build();
        HttpPost httpPost = new HttpPost(url);
        httpPost.setConfig(requestConfig);
        MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
        multipartEntityBuilder.addBinaryBody("file", imagedata, ContentType.APPLICATION_OCTET_STREAM,"name");
        multipartEntityBuilder.addTextBody("comment", "this is comment");
        HttpEntity httpEntity = multipartEntityBuilder.build();
        httpPost.setEntity(httpEntity);

        String result = "";
        try {
            httpResponse = httpClient.execute(httpPost);
            HttpEntity responseEntity = httpResponse.getEntity();
            int statusCode = httpResponse.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                result = EntityUtils.toString(responseEntity);
            }
        } catch (IOException e) {
            throw new Exception("上传失败");
        } finally {
            try {
                httpClient.close();
                if (httpResponse != null) {
                    httpResponse.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return result;
    }
//
//    private static final OkHttpClient client = new OkHttpClient();
//
//    private static MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
//
//    public static String snEncode(String sn) throws UnsupportedEncodingException {
//        String snDecode = null;
//        if (StringUtils.isNotEmpty(sn)) {
//            snDecode = Base64.getEncoder().encodeToString(sn.getBytes("utf-8"));
//        }
//        return snDecode;
//    }
//
//    private Request auth(Request.Builder builder,String userName,String password) throws UnsupportedEncodingException {
//        if (StringUtils.isNotBlank(userName)) {
//            builder.header("Authorization", String.format("Basic %s", snEncode(String.format("%s:%s", userName, password))));
//        }
//        return builder.build();
//    }
//
//    /**
//     * OK http3 通用请求
//     *
//     * @param json
//     * @param url
//     * @return
//     */
//    public String okHttpRequest(String json, String url,String userName,String password) throws IOException {
//        RequestBody requestBody = RequestBody.create(mediaType, json);
//        Request.Builder builder = new Request.Builder()
//                .url(url)
//                .header("Content-type", "application/json; charset=utf-8")
//                .header("Content-Length", String.valueOf(json.length()))
//                .post(requestBody);
//
//        Response response = null;
//            Request request = this.auth(builder,userName,password);
//            response = client.newCall(request).execute();
//            response.close();
//        if (response.isSuccessful()) {
//            try {
//                return response.body().string();
//            } catch (IOException e) {
//                return null;
//            }
//        }
//        return null;
//    }


    public static void main(String[] args) throws Exception {
        String result = doGet("https://www.cnblogs.com","/qinxu/p/7979070.html",new HashMap<>(),new HashMap<>());
//        String result = doPost("https://www.cnblogs.com", "/qinxu/p/7979070.html", new HashMap<>(), new HashMap<>(), new HashMap<>());
        System.out.println("result------------------------------------------------：\n\n\n"+result);
    }
}

